package com.hellobike.haxing.modules.product.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import com.hellobike.haxing.modules.product.entity.PromotionFlashSku;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Update;

/**
 * @Description: 限时抢购SKU
 * @Author: haxing-boot
 * @Date:   2020-01-31
 * @Version: V1.0
 */
public interface PromotionFlashSkuMapper extends BaseMapper<PromotionFlashSku> {

    @Update("UPDATE t_promotion_flash_sku SET stock_left = stock_left + #{changeNum} WHERE id = #{flashSkuId} AND stock_left >= 0 - #{changeNum} AND deleted = 0")
    int changeFlashSkuStock(@Param("flashSkuId") Long flashSkuId, @Param("changeNum") Integer changeNum);

}
